package com.kaifamiao.io.d0921;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class BufferedInputStreamDemo {

    public static void main(String[] args) {
        try (FileInputStream fis = new FileInputStream("d:\\io\\buffer.txt");
            BufferedInputStream bis = new BufferedInputStream(fis);){

            int content = -1;
            while( ( content = bis.read()) != -1){
                if(content == 101){
                    bis.mark(1);
                }
                System.out.print(content);
            }

            System.out.println();
            // 重置
            bis.reset();

            System.out.println(bis.available());

            System.out.println(bis.read());

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
